#include<bits/stdc++.h>
using namespace std;
int T, n, m, tot, ans;//tot:overspeed;ans:shutdown p;
float L, V, d, v, a, t, s, nd;
priority_queue<float> pp, pdisup, pdisd, pdisd0;
bool b=1;
vector<float> p, disup, disd;
void spdup(){
    pdisup.push(s);//dis
 //   cout<<"up:"<<s<<endl;
    return;
}
void spddown(){
    pdisd.push(s);//dis
    pdisd0.push(d);
 //   cout<<"down:"<<s<<endl;
    return;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    for(int i=1;i<=T;i++){
        scanf("%d%d%f%f",&n, &m, &L, &V);
        nd=L;
            for(int j=1;j<=n;j++){
                scanf("%f%f%f", &d, &v, &a);
                if(v<=V){
                    if(a<=0)continue;
                    t=(V-v)/a;
                    s=d+t*v+0.5*a*t*t;
                    if(s>L)continue;
                    spdup();
                }
                else{//v0>V
                    if(a>=0){
                        s=d;
                        spdup();
                        continue;
                    }
                    t=(V-v)/a;
                    s=d+t*v+0.5*a*t*t;
                    spddown();
                }
            }//car
            for(int k=1;k<=m;k++){
                scanf("%f",&s);
                pp.push(s);
            }//checker
            while(!pp.empty()){
                p.push_back(pp.top());
                pp.pop();
            }
            while(!pdisup.empty()&&b){
                s=pdisup.top();
                for(t=0;t<m;t++){//borrow t for i;
                    if(p[t]>=s){
                //            cout<<"Furthest:"<<s<<' '<<p[t]<<endl;
                        tot+=pdisup.size();
                        cout<<'t'<<tot<<endl;
                        ans++;//p needed
                        b=0;
                        break;
                    }
                }
                pdisup.pop();
            }
            while(!pdisd.empty()){
                s=pdisd.top();
                d=pdisd0.top();
                for(t=0;t<m;t++){//borrow t for i;
                    if(p[t]<=s&&p[t]>=d){
                   //         cout<<"Nearest:"<<s<<' '<<p[t]<<endl;
                        tot++;
                        cout<<'T'<<tot<<endl;
                      //  ans++;//p needed
                    }
                }
                ans++;
                pdisd.pop();
                pdisd0.pop();
            }
        printf("%d%c%d\n",tot, ' ', (m-ans));
    }
    return 0;
}
